<template>
  <div class="base-card" :class="[
    shadow ? 'has-shadow' : '',
    hover ? 'hover-effect' : '',
    `radius-${radius}`,
    className
  ]">
    <div v-if="$slots.header || title" class="card-header">
      <div v-if="title" class="card-title">{{ title }}</div>
      <slot name="header"></slot>
    </div>
    <div class="card-body" :style="bodyStyle">
      <slot></slot>
    </div>
    <div v-if="$slots.footer" class="card-footer">
      <slot name="footer"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'BaseCard',
  props: {
    title: {
      type: String,
      default: ''
    },
    shadow: {
      type: Boolean,
      default: true
    },
    hover: {
      type: Boolean,
      default: false
    },
    radius: {
      type: String,
      default: 'md',
      validator: (value) => ['none', 'sm', 'md', 'lg'].includes(value)
    },
    bodyStyle: {
      type: Object,
      default: () => ({})
    },
    className: {
      type: String,
      default: ''
    }
  }
}
</script>

<style scoped>
.base-card {
  background-color: var(--background-white);
  border-radius: 0;
  overflow: hidden;
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.has-shadow {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.hover-effect:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.radius-none {
  border-radius: 0;
}

.radius-sm {
  border-radius: var(--border-radius-sm);
}

.radius-md {
  border-radius: var(--border-radius-md);
}

.radius-lg {
  border-radius: var(--border-radius-lg);
}

.card-header {
  padding: 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  padding: 16px;
}

.card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--divider);
  background-color: var(--background-grey);
}

/* 移动端优化 */
@media (max-width: 768px) {
  .base-card {
    margin-bottom: 12px;
  }
  
  .card-header {
    padding: 12px 16px;
  }
  
  .card-body {
    padding: 12px 16px;
  }
  
  .card-footer {
    padding: 10px 16px;
  }
}
</style> 